<template>
  <div class="center-container">

    <el-form class="form-container" style="margin-top: -50px;">
      <div style="font-size: 25px; font-weight: bold; margin-top: 20px; margin-left: 100px;">发送至官方邮件</div>
      <div style="height: 50px"></div>
      <el-form-item label="邮箱" style="width: 350px" label-width="100px">
        <el-input v-model="email" placeholder="请输入您的邮箱"></el-input>
      </el-form-item>
      <el-form-item label="手机号" style="width: 350px" label-width="100px">
        <el-input v-model="phone" placeholder="请输入您的手机号"></el-input>
      </el-form-item>
      <el-form-item label="姓名" style="width: 350px" label-width="100px">
        <el-input v-model="name" placeholder="请输入您的姓名"></el-input>
      </el-form-item>
      <el-form-item label="邮件内容" label-width="100px">
        <vue-editor v-model="message" style="width: 900px" placeholder="请输入内容"></vue-editor>
<!--        <el-input type="textarea" v-model="message" :rows="10" placeholder="请输入内容"></el-input>-->
      </el-form-item>
      <el-form-item class="centered-label" label-width="400px">
        <el-button type="primary" @click="submitForm()">发送</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { VueEditor } from 'vue2-editor'
import {sendEmail} from '../../../../api/api'
export default {
  name: 'email',
  inject: ['reload'],
  components: {
    VueEditor
  },
  data () {
    return {
      email: '',
      name: '',
      phone: '',
      message: ''
    }
  },
  methods: {
    submitForm () {
      sendEmail(this.email, this.phone, this.name, this.message)
        .then((res) => {
          if (res.ok) {
            this.$message.success('发送成功！')
          } else {
            this.$message.error('发送失败！')
          }
        })
        .catch((e) => {
          throw e
        })
    }
  }
}
</script>
<style>
.center-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
}

.form-container {
  width: 70%;
}
</style>
